var form = layui.form
$(function () {
    // console.log('1');
    form.verify({
        pass: [
            /^[\S]{6,12}$/
            , '密码必须6到12位，且不能出现空格'
        ],
        newpass: function (value) {
            if (value === $("[name=oldPwd]").val()) return '新密码不能等于旧密码'
        },
        repass: function (value) {
            if (value !== $('[name=newPwd]').val())
                return '密码不一致'
        }
    });
})
$(".layui-form").on('submit', function (e) {
    e.preventDefault()
    $.ajax({
        type: "post",
        url: "/my/updatepwd",
        data: $(this).serialize(),
        success: function (res) {
            if (res.status != 0)
                return layui.layer.msg(res.message)
            layui.layer.msg(res.message + '请重新登录')
            // console.log(res);
            $('.layui-form')[0].reset()
            localStorage.removeItem('token')
            window.parent.getUser()
        }
    });
})